/**
 * 
 */
package com.org.javabody.DoubleApi.DoubleCompareTo;

import java.math.BigDecimal;

/**

 * @author Administrator

 *

 */
public class DoubleCompareToDemo {

	public static void compareTo(Double a,Double b) { //Double类型是一个对象不能用==比较

		boolean flag = false;
		if(a==b) {
			flag = true;
		} else {
			flag = false;
		}
		System.out.println(flag);
	}
	
	public static void compareTo1(double a,double b) { //换成double比较

		boolean flag = false;
		if(a==b) {
			flag = true;
		} else {
			flag = false;
		}
		System.out.println(flag);
	}
	
	public static void compareTo2(Double a,Double b) { //对象比较


		boolean flag = false;
		if(a.compareTo(b)==0) {
			flag = true;
		} else {
			flag = false;
		}
		System.out.println(flag);
	}
	
	
	public static void compareTo3(Double a,Double b) { //对象比较，随便小数点后多少位

		BigDecimal aa = BigDecimal.valueOf(a);
		BigDecimal bb = BigDecimal.valueOf(b);
		boolean flag = false;
		if(aa.compareTo(bb)==0) {
			flag = true;
		} else {
			flag = false;
		}
		System.out.println(flag);
	}
	
	/**

	 * @param args

	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub


		compareTo(1.00,1.00);
		compareTo1(1.00,1.00);
		compareTo2(1.0000000000001,1.0000000000001);
		compareTo3(1.0000,1.00000);
	}

}